import { createRouter, createWebHashHistory, createWebHistory } from 'vue-router'

import navbarConfig from './navbar.config'
import pageConfig from './page.config'
import schoolConfig from './school.config';
import userInfoConfig from "@/router/userInfo.config";
import addConfig from '@/router/add.config'

import MainLayout from '@/layout/main.vue'
import PageLayout from '@/layout/page.vue'
import SchoolLayout from '@/layout/school.vue'
import UserInfoLayout from '@/layout/userInfo.vue'
import AddLayout from '@/layout/add.vue'

const router = createRouter({
  history: createWebHashHistory(),
  routes: [{
    path: '',
    component: MainLayout,
    redirect: navbarConfig[0] || '/404',
    children: navbarConfig
  }, {
    path: '/page',
    component: PageLayout,
    children: pageConfig
  }, {
    path: '/school',
    component: SchoolLayout,
    children: schoolConfig
  },  {
    path: '/add',
    component: AddLayout,
    children: addConfig
  },{
    name: 'login',
    path: '/login',
    component: () => import("@/views/Login.vue")
  },{
    path: '/userInfo',
    component: UserInfoLayout,
    children: userInfoConfig
  },{
    name: 'person-search-add',
    path:'/person-search-add',
    component: () => import("@/views/addressbook/person/SearchAdd.vue")
  },
  {
    name: 'person-show-add',
    path:'/person-show-add',
    component: () => import("@/views/addressbook/person/ShowAdd.vue")
  },{
    name: 'group-search-add',
    path:'/group-search-add',
    component: () => import("@/views/addressbook/group/SearchAdd.vue")
  },
  {
    name: 'group-show-add',
    path:'/group-show-add',
    component: () => import("@/views/addressbook/group/ShowAdd.vue")
  },

  {
    name:'chat-person',
    path:'/chat-person',
    component: () => import("@/views/chat/person/index.vue")
  },{
    name:'chat-group',
    path:'/chat-group',
    component: () => import("@/views/chat/group/index.vue"),
    redirect:'/chat',
    children:[
      {
        name:'group-detail',
        path:'/detail',
        component: () => import("@/components/ChatComponent/GroupDetail.vue")
      },
      {
        name:'chat',
        path:'/chat',
        component: () => import("@/views/chat/group/Chat.vue")
      }
    ]
  },
]
})

export default router
